package com.caleble.sample.bo;

import java.io.FileInputStream;
import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.caleble.sample.dao.ibatis.MessageDAOImpl;
import com.caleble.sample.domain.Message;

@Controller
@Scope("prototype")
public class IbatisLob {
	@Autowired
	public MessageDAOImpl messageDAOImpl;

	@RequestMapping("/test.do")
	public String insert() throws IOException {

		FileInputStream is = new FileInputStream("D:/1.jpg");
		byte[] image = new byte[is.available()];
		is.read(image);

		Message message = new Message();
		message.setMsgid("1");
		StringBuffer content = new StringBuffer();
		for (int i = 0; i < 1000; i++)
			content.append("11111111111" + i);
		message.setContent(content.toString());
		message.setImage(image);

		is.close();

		messageDAOImpl.insert(message);
		return "ibatisLob";
	}

}
